package hbase

import org.apache.hadoop.hbase.client.Connection

/**
 * 连接HBase, 创建HBase执行对象
 * 1. 初始化配置信息：多条(hbase.zookeeper.quorum=>ip:2181)
 *      Configuration conf = HBaseConfiguration.create()
 *      conf.set(String, String)
 * 2. 创建连接：多个连接(池化)
 *      Connection con = ConnectionFactory.createConnection()
 * 3. 创建数据表：表名: String
 *      Table table = con.getTable(TableName)
 */

trait HBase {

  protected var statusCode: Int = -1
  /**
   * 1、初始化配置信息
   *  build() => statusCode 0
   */
  def build(): HBase

  /**
   * 2、创建连接：多个连接(池化)
   * @param available 是否删除
   * @param con 连接对像
   */
  case class PoolCon(var available: Boolean, con: Connection) {
    def out = {
      available = false
      this
    }
    def in = available = true
  }
  /**
   * 2、创建连接对象
   *  initPool() 初始化连接池 => statusCode 1
   */
  def initPool(): HBase
  /**
   * 3、完成
   *  finish() 初始化完成 => statusCode 2
   */
  def finish(): Executor
}
